﻿using SoftSource.Ria;
using SoftSource.Timecard.Web.Data;

namespace SoftSource.Timecard.Model
{
    public sealed partial class AdministratorModel : IModelEntities
    {
        #region Initalize Entity Wrappers
        private void InitializeEntityWrappers()
        {
            this.InitializeStaticReadOnlyEntityWrappers();
            this.InitializeReadOnlyEntityWrappers();
            this.InitializeReadWriteEntityWrappers();
        }

        private void InitializeStaticReadOnlyEntityWrappers()
        {
            this.Roles = new ReadOnlyEntityWrapper<Role>(this.staticTypes, this.staticTypes.GetRolesQuery);
            this.Reports = new ReadOnlyEntityWrapper<Report>(this.staticTypes, this.staticTypes.GetReportsQuery);
            this.UserTypes = new ReadOnlyEntityWrapper<UserType>(this.staticTypes, this.staticTypes.GetUserTypesQuery);
            this.ProjectTypes = new ReadOnlyEntityWrapper<ProjectType>(this.staticTypes, this.staticTypes.GetProjectTypesQuery);
            this.RevenueTypes = new ReadOnlyEntityWrapper<RevenueType>(this.staticTypes, this.staticTypes.GetRevenueTypesQuery);
            this.BillingStates = new ReadOnlyEntityWrapper<BillingState>(this.staticTypes, this.staticTypes.GetBillingStatesQuery);
            this.ProjectStatuses = new ReadOnlyEntityWrapper<ProjectStatus>(this.staticTypes, this.staticTypes.GetProjectStatusQuery);
            this.BillingFrequencies = new ReadOnlyEntityWrapper<BillingFrequency>(this.staticTypes, this.staticTypes.GetBillingFrequenciesQuery);
        }

        private void InitializeReadOnlyEntityWrappers()
        {
            this.UserSummaries = new ReadOnlyEntityWrapper<UserSummary>(this.readOnlyTypes, this.readOnlyTypes.GetUserSummariesQuery);
            this.ProjectSummaries = new ReadOnlyEntityWrapper<ProjectSummary>(this.readOnlyTypes, this.readOnlyTypes.GetProjectSummariesQuery);
            this.CategorySummaries = new ReadOnlyEntityWrapper<CategorySummary>(this.readOnlyTypes, this.readOnlyTypes.GetCategorySummariesQuery);
            this.CustomerSummaries = new ReadOnlyEntityWrapper<CustomerSummary>(this.readOnlyTypes, this.readOnlyTypes.GetCustomerSummariesQuery);
            this.MilestoneSummaries = new ReadOnlyEntityWrapper<MilestoneSummary>(this.readOnlyTypes, this.readOnlyTypes.GetMilestoneSummariesQuery);
            this.CustomerUserSummaries = new ReadOnlyEntityWrapper<CustomerUserSummary>(this.readOnlyTypes, this.readOnlyTypes.GetCustomerUserSummariesQuery);
            this.ProjectMemberSummaries = new ReadOnlyEntityWrapper<ProjectMemberSummary>(this.readOnlyTypes, this.readOnlyTypes.GetProjectMemberSummariesQuery);
            this.ProjectCategorySummaries = new ReadOnlyEntityWrapper<ProjectCategorySummary>(this.readOnlyTypes, this.readOnlyTypes.GetProjectCategorySummariesQuery);
            this.CustomerProjectSummaries = new ReadOnlyEntityWrapper<CustomerProjectSummary>(this.readOnlyTypes, this.readOnlyTypes.GetCustomerProjectSummariesQuery);
        }

        private void InitializeReadWriteEntityWrappers()
        {
            this.Users = new EntityWrapper<User>(this.users);
            this.Entries = new EntityWrapper<EntryLog>(this.entries);
            this.Projects = new EntityWrapper<Project>(this.projects);
            this.Customers = new EntityWrapper<Customer>(this.customers, this.customers.GetCustomersQuery);
            this.Categories = new EntityWrapper<Category>(this.categories, this.categories.GetCategoriesQuery);
            this.Milestones = new EntityWrapper<Milestone>(this.milestones, this.milestones.GetMilestonesQuery);
            this.CustomerUsers = new EntityWrapper<CustomerUser>(this.customers, this.customers.GetCustomerUserQuery);
            this.ProjectMembers = new EntityWrapper<ProjectMember>(this.projects, this.projects.GetProjectMembersQuery);
            this.ProjectCategories = new EntityWrapper<ProjectCategory>(this.projects, this.projects.GetProjectCategoriesQuery);
            this.CustomerProjects = new EntityWrapper<CustomerProject>(this.customers, this.customers.GetCustomersProjectsQuery);
            this.InvoicingProjects = new EntityWrapper<InvoicingProject>(this.invoicingContext, this.invoicingContext.GetInvoicingProjectsQuery);
        }
        #endregion Initalize Entity Wrappers

        #region Static
        public ReadOnlyEntityWrapper<Role> Roles { get; private set; }
        public ReadOnlyEntityWrapper<Report> Reports { get; private set; }
        public ReadOnlyEntityWrapper<UserType> UserTypes { get; private set; }
        public ReadOnlyEntityWrapper<ProjectType> ProjectTypes { get; private set; }
        public ReadOnlyEntityWrapper<RevenueType> RevenueTypes { get; private set; }
        public ReadOnlyEntityWrapper<BillingState> BillingStates { get; private set; }
        public ReadOnlyEntityWrapper<ProjectStatus> ProjectStatuses { get; private set; }
        public ReadOnlyEntityWrapper<BillingFrequency> BillingFrequencies { get; private set; }
        #endregion Static

        #region Read-Only
        public ReadOnlyEntityWrapper<UserSummary> UserSummaries { get; private set; }
        public ReadOnlyEntityWrapper<ProjectSummary> ProjectSummaries { get; private set; }
        public ReadOnlyEntityWrapper<CategorySummary> CategorySummaries { get; private set; }
        public ReadOnlyEntityWrapper<CustomerSummary> CustomerSummaries { get; private set; }
        public ReadOnlyEntityWrapper<MilestoneSummary> MilestoneSummaries { get; private set; }
        public ReadOnlyEntityWrapper<CustomerUserSummary> CustomerUserSummaries { get; private set; }
        public ReadOnlyEntityWrapper<ProjectMemberSummary> ProjectMemberSummaries { get; private set; }
        public ReadOnlyEntityWrapper<ProjectCategorySummary> ProjectCategorySummaries { get; private set; }
        public ReadOnlyEntityWrapper<CustomerProjectSummary> CustomerProjectSummaries { get; private set; }
        #endregion Read-Only

        #region Read-Write
        public EntityWrapper<User> Users { get; private set; }
        public EntityWrapper<EntryLog> Entries { get; private set; }
        public EntityWrapper<Project> Projects { get; private set; }
        public EntityWrapper<Customer> Customers { get; private set; }
        public EntityWrapper<Category> Categories { get; private set; }
        public EntityWrapper<Milestone> Milestones { get; private set; }
        public EntityWrapper<CustomerUser> CustomerUsers { get; private set; }
        public EntityWrapper<ProjectMember> ProjectMembers { get; private set; }
        public EntityWrapper<CustomerProject> CustomerProjects { get; private set; }
        public EntityWrapper<ProjectCategory> ProjectCategories { get; private set; }
        public EntityWrapper<InvoicingProject> InvoicingProjects { get; private set; }
        #endregion Read-Write
    }
}
